fix: performance improvements (#312) - #356
Conversation
…nModule cache, async WMI (#312)
📝 WalkthroughWalkthroughPR 356 implements five localized performance and threading improvements: case-insensitive path comparisons without allocation overhead, consolidated process module access, streaming file hashing, and async environment info collection to prevent UI blocking. ChangesPerformance and Threading Optimizations
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@SysManager/SysManager/ViewModels/AboutViewModel.cs`:
- Around line 220-237: The method CopyEnvironmentInfoAsync currently sets
UpdateStatus to success unconditionally; update it to only set the success
message after a confirmed successful Clipboard.SetText call, and handle failure
paths: call CollectEnvironmentInfo() and if it returns null/empty or an
error-indicating string (handle the known error format your
CollectEnvironmentInfo returns) set UpdateStatus to an error message and skip
Clipboard.SetText; wrap Clipboard.SetText in the existing catch for
System.Runtime.InteropServices.ExternalException but set UpdateStatus to a
failure message (including ex.Message) instead of leaving the success text; keep
the existing catches for ManagementException and InvalidOperationException but
ensure they set appropriate UpdateStatus values as currently done.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bdfade6a-e10b-4f3e-a7c5-79ad8b49e08e
📒 Files selected for processing (6)
CHANGELOG.mdSysManager/SysManager/Services/DuplicateFileService.csSysManager/SysManager/Services/LargeFileScanner.csSysManager/SysManager/Services/ProcessManagerService.csSysManager/SysManager/Services/SpeedTestService.csSysManager/SysManager/ViewModels/AboutViewModel.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build & unit tests
- GitHub Check: Analyze (csharp)
🔇 Additional comments (5)
SysManager/SysManager/Services/DuplicateFileService.cs (1)
229-229: LGTM!SysManager/SysManager/Services/LargeFileScanner.cs (1)
128-128: LGTM!SysManager/SysManager/Services/SpeedTestService.cs (1)
300-301: LGTM!CHANGELOG.md (1)
9-21: LGTM!SysManager/SysManager/Services/ProcessManagerService.cs (1)
74-79: LGTM!
| private async Task CopyEnvironmentInfoAsync() | ||
| { | ||
| try | ||
| { | ||
| var text = await Task.Run(() => CollectEnvironmentInfo()).ConfigureAwait(true); | ||
| try { Clipboard.SetText(text); } | ||
| catch (System.Runtime.InteropServices.ExternalException ex) { Log.Debug("Clipboard locked: {Error}", ex.Message); } | ||
| UpdateStatus = "Environment info copied to clipboard."; | ||
| } | ||
| catch (System.Management.ManagementException ex) | ||
| { | ||
| UpdateStatus = $"Couldn't collect environment info: {ex.Message}"; | ||
| } | ||
| catch (InvalidOperationException ex) | ||
| { | ||
| UpdateStatus = $"Couldn't collect environment info: {ex.Message}"; | ||
| } | ||
| } |
There was a problem hiding this comment.
Fix false-success status when clipboard copy fails.
UpdateStatus is set to success even when Clipboard.SetText throws, so users can get a “copied” message without data actually copied. Also, because CollectEnvironmentInfo() returns error text instead of throwing, this method should explicitly handle that return path before claiming success.
💡 Suggested fix
private async Task CopyEnvironmentInfoAsync()
{
- try
- {
- var text = await Task.Run(() => CollectEnvironmentInfo()).ConfigureAwait(true);
- try { Clipboard.SetText(text); }
- catch (System.Runtime.InteropServices.ExternalException ex) { Log.Debug("Clipboard locked: {Error}", ex.Message); }
- UpdateStatus = "Environment info copied to clipboard.";
- }
- catch (System.Management.ManagementException ex)
- {
- UpdateStatus = $"Couldn't collect environment info: {ex.Message}";
- }
- catch (InvalidOperationException ex)
- {
- UpdateStatus = $"Couldn't collect environment info: {ex.Message}";
- }
+ var text = await Task.Run(CollectEnvironmentInfo).ConfigureAwait(true);
+ if (text.StartsWith("Couldn't collect environment info:", StringComparison.Ordinal))
+ {
+ UpdateStatus = text;
+ return;
+ }
+
+ try
+ {
+ Clipboard.SetText(text);
+ UpdateStatus = "Environment info copied to clipboard.";
+ }
+ catch (System.Runtime.InteropServices.ExternalException ex)
+ {
+ Log.Debug("Clipboard locked: {Error}", ex.Message);
+ UpdateStatus = "Couldn't copy environment info: clipboard is currently in use.";
+ }
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@SysManager/SysManager/ViewModels/AboutViewModel.cs` around lines 220 - 237,
The method CopyEnvironmentInfoAsync currently sets UpdateStatus to success
unconditionally; update it to only set the success message after a confirmed
successful Clipboard.SetText call, and handle failure paths: call
CollectEnvironmentInfo() and if it returns null/empty or an error-indicating
string (handle the known error format your CollectEnvironmentInfo returns) set
UpdateStatus to an error message and skip Clipboard.SetText; wrap
Clipboard.SetText in the existing catch for
System.Runtime.InteropServices.ExternalException but set UpdateStatus to a
failure message (including ex.Message) instead of leaving the success text; keep
the existing catches for ManagementException and InvalidOperationException but
ensure they set appropriate UpdateStatus values as currently done.
Add CHANGELOG entry for v0.28.8 — Process Manager Open file location fix + Show only apps toggle. Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
Summary
Addresses 5 of 6 performance issues from the code review (PERF-002/004/005/008).
Changes
Not addressed (lower priority, separate PR)
Closes #312
Summary by CodeRabbit
Chores
Performance